#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName :cp2_2.20.py
# @Time     :2023/8/20 23:14
# @Author   :Ash
from array import array
from random import random

if __name__ == "__main__":
    floats = array('d', (random() for i in range(10**7)))
    print(floats[-1])
    fp = open('../assets/floats.bin', 'wb')
    floats.tofile(fp)
    fp.close()
    floats2 = array('d')
    fp = open('../assets/floats.bin', 'rb')
    floats2.fromfile(fp, 10**7)
    fp.close()
    print(floats2[-1])
    print(floats2 == floats)
